package unipi.servlets;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import unipi.helpers.HTMLPages;
import unipi.helpers.LoginCookie;

public class Help extends HttpServlet
{
	private static final long serialVersionUID = 1L;
	
	public Help()
	{
		super();
	}
	
	public void init() throws ServletException
	{
		
	
	}
	
	private String getPage(String uid, String pdfpath)
	{
		String content = "<h1>Βοήθεια</h1>";
		
		content += "<div id=\"pdf\">\r\n" + 
					"  <object width=\"100%\" height=\"1170\" type=\"application/x-pdf\"" +
					"		   data=\"" + pdfpath + "\" id=\"pdf_content\">" + 
					"    <div>Δεν μπορεί να φορτώσει το pdf...</div>" + 
					"  </object>" + 
					"</div><br />";
		
		return HTMLPages.getGeneralPage(content, uid);	
	}
	
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
	{
		if(!LoginCookie.authCookie(request))
			response.sendRedirect("Login");
		else
		{
			String uid = LoginCookie.Get(request)[0];
			
			response.setContentType("text/html; charset=UTF-8");	
			PrintWriter out = response.getWriter();
			
			out.println(getPage(uid, "custom/manual.pdf"));
			
			out.close();			
		}
	}
	
}
